#include<iostream>
#include<cstring>

using namespace std;

const int N=30;

int book[N];

int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		memset(book,0,sizeof book);
		string s;
		cin>>s;
		int one=0,two=0;
		for(int i=0;i<s.size();i++) book[s[i]-'a']++;
		
		for(int i=0;i<26;i++)
		{
			if(book[i] == 1) one++;
			else if(book[i] > 1) two++; 
		}
		
		printf("%d\n",two+(one)/2);
	}
	return 0;
}
